package com.blood.core.util;

import com.blood.core.resp.BusinessException;
import com.blood.core.resp.GlobalResultStatus;
import org.apache.commons.lang3.StringUtils;

/**
 * 断言工具类
 *
 * @author daoren
 */
public class ObjectAssertUtil {
    public static void stringIsNull(String value, String msg) {
        if (StringUtils.isBlank(value)) {
            throw new BusinessException(GlobalResultStatus.FAIL, msg);
        }
    }

    public static void stringIsNull(String value, GlobalResultStatus status) {
        if (StringUtils.isBlank(value)) {
            throw new BusinessException(status);
        }
    }

    public static void stringIsNull(String value, GlobalResultStatus status, String msg) {
        if (StringUtils.isBlank(value)) {
            throw new BusinessException(status, msg);
        }
    }

    public static void objectIsNull(Object object, String msg) {
        if (null == object) {
            throw new BusinessException(GlobalResultStatus.FAIL, msg);
        }
    }

    public static void objectIsNotNull(Object object, String msg) {
        if (null != object) {
            throw new BusinessException(GlobalResultStatus.FAIL, msg);
        }
    }

    public static void objectIsNull(Object object, GlobalResultStatus status) {
        if (null == object) {
            throw new BusinessException(status);
        }
    }

    public static void objectIsNull(Object object, GlobalResultStatus status, String msg) {
        if (null == object) {
            throw new BusinessException(status, msg);
        }
    }

    public static void isBoolean(boolean value, String msg) {
        if (value) {
            throw new BusinessException(GlobalResultStatus.FAIL, msg);
        }
    }

    public static void isBoolean(boolean value, GlobalResultStatus status) {
        if (value) {
            throw new BusinessException(status);
        }
    }

    public static void isBoolean(boolean value, GlobalResultStatus status, String msg) {
        if (value) {
            throw new BusinessException(status, msg);
        }
    }
}
